
if exists (select 1 from sysobjects where name = 'vw_planrow' and type = 'V')
begin
   drop view vw_planrow
   print 'View: vw_planrow deleted ...'
end
go
create view vw_planrow
as

   select name = ap.Name,
          schemaid = ap.SchemaID,
          prsschemaid = ps.PrsSchemaID,
          prsid = ps.PrsID,
          rowcolor = ps.RGB,
          rowcolorname = ps.ColorName,
          tage = datepart(day,ap.Bis)
     from ArbeitsPlan ap
    inner join PlanSchema ps
       on ps.SchemaID = ap.SchemaID
--where ap.planid = 9

go
print 'View: vw_planrow done ...'
go

grant select on vw_planrow to prsadmins with grant option
go
grant select on vw_planrow to prsusers
go






